#include"test.h"
#include<iostream>
#include<cstring>
using namespace std;

Test::~Test()
{
	
	delete[] m_p;
	m_p = NULL;
}
void Test::search(int n)
{
	int i=0;
	for(i=0;i<m_num;i++)
	{
		if(m_p[i]==n)
		{
			cout <<"下标是"<< i <<endl;
		}
	}
}
void Test::traval()
{
	int i=0;
	for(i = 0; i < m_num; i++)
	{
		cout << m_p[i] << " " << endl;
	}
}
void Test::revise(int n)
{
}
int Test::add(int index, int elm)
{
	if(m_num==m_const)
	{
		cout << "满了" << endl;
		return 0;
	}
	if(m_num>0)
	memmove((int*)m_p+index,(int*)m_p+index+1,m_num-index-1);
	m_p[index] = elm;
	m_num+=1;
		return 1;
}
void Test::del(int n)
{
	int i=0;
	for(i=0;i<m_num;i++)
	{
		if(m_p[i]==n)
		{
			memcpy((int*)m_p+i,(int*)m_p+i+1,m_num-i-1);
			break;
		}
	}
	m_num--;
}
int Test::update(int oldElm,int newElm)
{
	int i=0;
	for(i=0;i<m_num;i++)
	{
		if(m_p[i]==oldElm)
		{
			m_p[i]=newElm;
		}
	}
	return 1;
}

